package com.xieyunjie;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;

/**
 * @program: 0812springboot
 * @author: 雷哥
 * @create: 2019-12-16 14:53
 **/
@Configuration
public class I18NConfig {

    @Bean
    public ResourceBundleMessageSource messageSource() {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        //使用.propertes里面的内容做为消息
        messageSource.setUseCodeAsDefaultMessage(true);
        messageSource.setFallbackToSystemLocale(false);

        messageSource.setBasename("application");
//        messageSource.setBasenames("app");
        //设置编码
        messageSource.setDefaultEncoding("UTF-8");
        //设置缓存时间  2秒
        messageSource.setCacheSeconds(2);
        return messageSource;
    }
}
